﻿@using Abp.Extensions
@{
    Layout = "~/Views/Shared/_Modal.cshtml"; 
}
@model  NavGuide.Guide.Dtos.NavigationDto
<h3>
    @if (!Model.IsEditMode)
    { <strong>新增</strong> }
    else
    {  <strong>修改</strong> }
</h3>
<hr />
<form id="form" name="testBankInformationsForm" role="form" novalidate class="form-validation">
    @Html.AntiForgeryToken()
    <input type="hidden" name="Id" value="@Model.Id" />
    <div class="row">
        <div class="form-group form-md-line-input form-md-floating-label  ">
            <label> 收藏夹 </label>  
            <input type="hidden" name="ParentId" value="@Model.ParentId" />
            @Model.Name
        </div>
        <div class="form-group form-md-line-input form-md-floating-label  ">
            <label>标题   <span class=""> * </span>	 	</label>
            <input class="maxlength-handler form-control @(Model.DisplayName.IsNullOrEmpty() ? "" : " edited")" type="text" name="DisplayName" value="@Model.DisplayName" required maxlength="120" />
        </div> 
        <div class="form-group form-md-line-input form-md-floating-label  ">
            <label>链接 </label>
            <input class="maxlength-handler form-control @(Model.Url.IsNullOrEmpty() ? "" : " edited")" type="text" name="Url" value="@Model.Url" maxlength="255" />
        </div>
        <div class="form-group form-md-line-input form-md-floating-label  ">
            <label>帐号 </label>
            <input class="maxlength-handler form-control @(Model.Account.IsNullOrEmpty() ? "" : " edited")" type="text" name="Account" value="@Model.Account" maxlength="200" />
        </div> 
        <div class="form-group form-md-line-input form-md-floating-label  ">
            <label>密码 </label>
            <input class="maxlength-handler form-control @(Model.Key.IsNullOrEmpty() ? "" : " edited")" type="text" name="Key" value="@Model.Key" maxlength="200" />
        </div> 
    </div>
</form>

@section Scripts{
    <script type="text/javascript">
        var modal = $("#@Request["ModalID"]");
        $("#id_submit").on("click",
            function () {
                var url = "/Guide/Add";
                $("#form").ajaxSubmit({
                    url: url,
                    type: "post",
                    success: function (res, status, xhr) {
                        var data = res.result;
                        console.log(data);
                        if (data.code >= 0) {
                            modal.modal('hide'); 
                            toastr.success(data.msg, "提交成功"); 
                        } else {
                            toastr.warning(data.msg, "提交失败");
                        }
                    },
                    error: function (err) {
                        toastr.warning("遇到错误", "提交失败");
                    }
                });
            });

    </script>
}